<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<!-- 导入jquery核心类库 -->
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<!-- 导入easyui类库 -->
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/ext/portal.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/default.css">	
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/ext/jquery.portal.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/ext/jquery.cookie.js"></script>
<script
	src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"
	type="text/javascript"></script>
		
<script type="text/javascript">

	$(function(){
		$("body").css({visibility:"visible"});
		//提交表单
		
		 $('#return').click(function(){
			 
				location.href="${pageContext.request.contextPath}/page.outputruler.ashx"

		 });

		//定义列
		var columns = [ [ 
		{
		field : 'username',
		title : '姓名',
		width : 120,	
	},{
		field : 'mobile',
		title : '电话',
		width : 120,
	},  {
		field : 'regdatetime',
		title : '注册时间',
		width : 120,
		formatter:formatterDate
	} , {
		field : 'email',
		title : '邮箱',
		width : 120,
	} ] ];
		
		
		var rulerId = $("#rid_input").val();


		// 收派标准数据表格
		$('#grid').datagrid( {
			iconCls : 'icon-forward',
			fit : true,
			border : false,
			rownumbers : true,
			singleSelect:true,
			striped : true,
			url : "${pageContext.request.contextPath}/page.listRulerUser.ashx",
			idField : 'id',
			columns : columns,
			pageList: [10,30,50,100],
			pagination:true,
			 view:myview,
			emptyMsg:"<font size=3>暂无记录</font>", 
			queryParams: {
				rulerId:rulerId
			}
	       
	       
			
		});

	  
		
	});
	
	var myview = $.extend({},$.fn.datagrid.defaults.view,{
		onAfterRender:function(target){
			$.fn.datagrid.defaults.view.onAfterRender.call(this,target);
			var opts = $(target).datagrid('options');
			var vc = $(target).datagrid('getPanel').children('div.datagrid-view');
			vc.children('div.datagrid-empty').remove();
			if (!$(target).datagrid('getRows').length){
				var d = $('<div class="datagrid-empty"></div>').html(opts.emptyMsg || 'no records').appendTo(vc);
				d.css({
					position:'relative',
					left:0,
					top:50,
					width:'100%',
					textAlign:'center'
				});
			}
		}
	});
	
	
	$(document).ready(function(){
		var a = $("#rGoWhere_input").val();
		if(a.toString()=='0'){
			$('#buyermessage_table').hide();
		}else if(a==1){
			$('#staffmessage_table').hide();

		}else{
			$('#staffmessage_table').hide();
		}
		$("#rVersion").html(formatterVersion($("#rversion_input").val()));
		$("#rSellTime").html(formatterDate($("#rselltime_input").val()));
		$("#rRukuTime").html(formatterDate($("#rrukutime_input").val()));
		$("#binserttime").html(formatterDate($("#binserttime_input").val()));
		$("#rState").html(formatterrState($("#rstate_input").val()));
		$("#rGoWhere").html(formatterrGoWhere($("#rGoWhere_input").val()));
		
	}); 
	
	function formatterrState(value,row,index){

		if(value==1){
			return "<font color='red'>出库</font>";
		}
		else if(value==0){
			return "库存";
		}else if(value==2){
			return "申请SN";
		}else if(value==3){
			return "已调试待入库";
		}else if(value==4){
			return "报废";
		}
	}
	
	function formatterrGoWhere(value,row,index){

		if(value.toString()=='0'){
			return "<font color='red'>员工自用</font>";
		}
		else if(value==1){
			return "售出";
		}
	}
	
	function formatterVersion(value){
		if(value.toString()=='0'){
			return "基础版";
		}else if(value==1){
			return "高定版";
		}else if(value==2){
			return "团装版";
		}else if(value==3){
			return "体验版";
		}else if(value==4){
			return "SDK版";
		}
	}
	
	function formatterDate(value){
		if(value==''||null==value){
			return '';
		}
		var now = new Date(parseInt(value) * 1000);  
		var year=now.getYear()+1900; 
		var month=now.getMonth()+1; 
		var date=now.getDate(); 
		var hour=now.getHours(); 
		var minute=now.getMinutes();
		minute= (minute > 9) ? minute=minute : minute='0'+minute;
		return year+"-"+month+"-"+date+" "+hour+":"+minute; 
	}
	
	window.onload=function(){}
	
	function formatterDate(value){
		if(value==''||null==value){
			return '';
		}
		var now = new Date(parseInt(value) * 1000);  
		var year=now.getYear()+1900; 
		var month=now.getMonth()+1; 
		var date=now.getDate(); 
		var hour=now.getHours(); 
		var minute=now.getMinutes();
		minute= (minute > 9) ? minute=minute : minute='0'+minute;
		//var second=now.getSeconds(); 
		return year+"-"+month+"-"+date+" "+hour+":"+minute; 
	}
</script>	
</head>

<body class="easyui-layout" style="visibility:hidden;">
	<div region="north" style="height:31px;overflow:hidden;" split="false" border="false" >
		<div class="datagrid-toolbar">
			<a id="return" icon="icon-undo" href="#" class="easyui-linkbutton" plain="true" >返回</a>
			
		</div>
	</div>
    <div region="center" style="overflow:auto;padding:5px;" border="false">
        
         <table class="table-edit"  width="95%" align="center">
           		<tr class="title"><td colspan="6">基本信息</td></tr>
 

	           	<tr>
	           		
	           		<td>SN地址:</td>
	           		<td >${r.rsn}</td>
					<td>偏差值:</td>
					<td id="oOPNumber">${r.rOffset}</td>
				</tr>  	 
				<tr>
					<td>产地:</td>
	           		<td >${r.rBrithplace}</td>
	           		<td>颜色:</td>
	           		<td >${r.rColor}</td>
				</tr> 
				
					<tr>
					<td>版本:</td>
	           		<td id="rVersion"></td>
	           		<input type="hidden"  id = "rversion_input" value="${r.rVersion}"/>
	           		<input type="hidden"  id = "rid_input" value="${r.rId}"/>
	           		<td>型号:</td>
	           		<td >${r.rType}</td>
				</tr> 
				
				<tr>
					
	           		<td>名称:</td>
	           		<td >${r.rName}</td>
	           		<td>状态</td>
					<td id="rState">${r.rState}</td>
				    <input type="hidden"  id = "rstate_input" value="${r.rState}"/>
				</tr>
					<tr>
	           		
					<td>出库时间:</td>
	           		<td id="rSellTime">${r.rSellTime}</td>
	           		<input type="hidden"  id = "rselltime_input" value="${r.rSellTime}"/>
					<td>入库时间:</td>
					<td id="rRukuTime"></td>
					<input type="hidden"  id = "rrukutime_input" value="${r.rRukuTime}"/>
					
				</tr>  
				<tr>
	           		
					<td>去向:</td>
	           		<td id="rGoWhere">${r.rGoWhere}</td>
	           		<input type="hidden"  id = "rGoWhere_input" value="${r.rGoWhere}"/>
					<td></td>
					<td></td>
					
				</tr>  	
			</table>
			
			<%--  <table class="table-edit"  width="95%" align="center">
           		<tr class="title"><td colspan="6">生命周期</td></tr>
            	<tr>
	           		<td>SN地址:</td>
	           		<td >${r.rsn}</td>
					<td>偏差值:</td>
					<td id="oOPNumber">${r.rOffset}</td>
				</tr>  	 
				<tr>
					<td>产地:</td>
	           		<td >${r.rBrithplace}</td>
	           		<td>颜色:</td>
	           		<td >${r.rColor}</td>
				</tr> 
			</table> --%>

				 <table id="buyermessage_table" type="hidden" class="table-edit"  width="95%" align="center">
           		<tr class="title"><td colspan="6">客户信息</td></tr>
            	<tr>
	           		<td>客户名称:</td>
	           		<td >${buyer.bName}</td>
					<td>联系人:</td>
					<td id="oOPNumber">${buyer.bContacts}</td>
				</tr>  	 
				<tr>
					<td>联系电话:</td>
	           		<td >${buyer.bTel}</td>
	           		<td>联系地址:</td>
	           		<td >${buyer.bAddress}</td>
				</tr> 
				<tr>
					<td>备注:</td>
	           		<td >${buyer.bRemark}</td>
	           		<td>录入时间:</td>
	           		<td id="binserttime"></td>
	           		<input hidden="hidden"  id = "binserttime_input" value="${buyer.bInsertTime}"/>
				</tr> 
			</table>
			
				 <table id="staffmessage_table" class="table-edit"  width="95%" align="center">
           		<tr class="title"><td colspan="6">使用该E尺的员工信息</td></tr>
            	<tr>
	           		<td>员工姓名:</td>
	           		<td >${rstaff.sName}</td>
					<td>联系电话:</td>
	           		<td >${rstaff.sPhone}</td>
				</tr>  	 
				
			</table>
			
			 <table class="table-edit"  width="95%" align="center">
           		<tr class="title"><td colspan="6">用户信息</td></tr>
			</table>
			
			<div style="height:48%;width:95%; margin:0 auto;" >
				<table  id="grid"></table>
			</div>
			
			
			
          
	</div>
</body>
</html>